<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page
	import="com.onlineMIS.common.Common_util,java.util.Date,java.text.SimpleDateFormat"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>禧乐仓连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>
<script>

function searchCustomer(){
	var clientName = $("#clientName").val();		
	if (clientName ==""){
		$.messager.alert('提示','请输入客户名字然后查询','warning');
	} else {
        var params= "clientName=" +clientName; 
        $.post("<%=request.getContextPath()%>/action/basicInforJSON!searchClients",params, backProcessSearchClient,"json");
	}
}
function backProcessSearchClient(data){
	var clients = data.clients;
	
    $('#clientTablebody tr').each(function () {                
        $(this).remove();
    });

    if (clients.length != 0){
	    for (var i = 0; i < clients.length; i++){
	    	var bg = "";
	    	if ((i % 2) == 0)
	    		bg = " style='background-color: rgb(255, 250, 208);'";
	        if (clients[i] != "")  
		          $("<tr align='center'  height='10' " + bg +"><td>"+clients[i].name+"</td><td>"+clients[i].region.name+"</td><td>"+clients[i].client_id+"</td><td>"+clients[i].currentFinance + "</td><td><a href='#' onclick='selectClient("+clients[i].client_id+",\""+clients[i].name+"," +clients[i].region.name +"\")'><img src='<%=request.getContextPath()%>/conf_files/web-image/editor.gif' border='0'/></a></td></tr>").appendTo("#clientTablebody");
	    }
    }else {
    	$("<tr class='InnerTableContent' height='10' style='background-color: rgb(255, 250, 208);' align='center'><td colspan=4><font color='red'>对应信息没有查询信息</font> </td></tr>").appendTo("#clientTablebody");
    }  
    $("#ClientDiv").dialog("open");
}
function selectClient(clientId, clientName,regionName){
	$("#clientID").val(clientId);
	$("#clientName").textbox("setValue",clientName);
	$("#ClientDiv").dialog("close");	 
	
}
function clearCustomer(){
	$("#clientID").val(0);
	$("#clientName").textbox("setValue","");
}

</script>
</head>

<s:hidden id="clientID" name="formBean.order.client_id" />
<s:textfield cssClass="easyui-searchbox" id="clientName" name="formBean.order.client_name"
					data-options="prompt:'请输入客户名称',searcher:searchCustomer"/>

<a href="#" class="easyui-linkbutton" id="clearBtn" data-options="iconCls:'icon-no'" onclick="clearCustomer();" style="width: 60px">清除</a>

<div id="ClientDiv" class="easyui-dialog" style="width: 590px; height: 300px" data-options="title:'查找客户',modal:false,closed:true,resizable:true">
	<table width="100%" align="center" class="OuterTable" bgcolor="#FFFFFF">
		<tr>
			<td>
				<table width="550" border="0">
					<tr class="InnerTableContent" style="background-color: #CCCCCC">
						<th width="170" height="10" aligen="center">客户名字</th>
						<th width="140" aligen="center">客户地区</th>
						<th width="60" aligen="center">精算账号</th>
						<th width="100" aligen="center">当前欠款</th>
						<th width="80" aligen="center"></th>
					</tr>
					<tbody id="clientTablebody">
					</tbody>
				</table>
			</td>
		</tr>
	</table>
</div>
</html>